package com.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class ghUnit {
    public static void gh(byte[] hash, byte[] message, int mlen) {
        try {
            // 初始化SHA-256消息摘要
            MessageDigest digest = MessageDigest.getInstance("SHA-256");

            // 处理消息
            digest.update(message, 0, mlen);

            // 计算最终的哈希值
            byte[] result = digest.digest();

            // 将结果复制到hash数组
            System.arraycopy(result, 0, hash, 0, result.length);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace(); // 处理异常
        }
    }
}
